<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Aloha Editor contenthandler Test Suite</title>
	<!-- include qunit -->
	<link rel="stylesheet" href="../vendor/qunit.css" type="text/css"/>

	<script type="text/javascript" src="../vendor/qunit.js"></script>

	<!-- include jquery -->
	<script	src="../../lib/vendor/jquery-3.7.0.js" ></script>
	<script type="text/javascript" src="../vendor/jquery.simulate.js"></script>

	<!-- include aloha -->
	<script>
		var Aloha = {
			settings: {
				jQuery: $,
				baseUrl: '../../lib',
				contentHandler: {
					insertHtml: [ 'sanitize', 'generic' ]
				}
			}
		};
	</script>
	<script src="../../lib/require.js"></script>
	<script src="../../lib/aloha.js" data-aloha-plugins="common/ui,common/list,common/format,common/commands,common/paste,common/contenthandler"></script>

	<script>
		// define realtive baseUrl path to requireJS
		// and paths back to aloha path
		require( [ 'commandtest' ] );
		//require( [ 'contenthandlertest' ] );
	</script>
</head>
<body>
	<!-- include the tests -->
	<script>
	var files, elements,
		tests = {
			defaultValue: 'bam',
			defaultCommand: 'inserthtml',
			label: 'sanitizecontenthandler',
			tests: [ ]
		},
		defaultAttributes = ['class','id']

	// now add tests for copy & paste from different sources (from './sanitizecontenthandler/<name>-[start|expected|value].html' files)
	files = [ 'validlink', 'attributelesslink', 'emptylink1', 'emptylink2', 'emptylink3' ];

	elements = [ 'div' ];

	for ( i=0; i<files.length; i++ ) {
		var data_start, 
			data_expected,
			data_value,
			data_attributes,
			file_expected,
			index;

		file = files[ i ];

		if (Aloha.settings.sanitize) {
			file_expected = file + '-' + Aloha.settings.sanitize;
		} else {
			file_expected = file;
		}
		
		var testUrl = 'sanitizecontenthandler/' + file +'-start.html';

		jQuery.ajax( {url: 'sanitizecontenthandler/' + file +'-start.html', async: false, success: function(data) { 
				data_start = data;
		}} );

		jQuery.ajax( {url: 'sanitizecontenthandler/' + file +'-expected.html', async: false, success: function(data) { 
				data_expected = data;
		}} );

		jQuery.ajax( {url: 'sanitizecontenthandler/' + file +'-value.html', async: false, success: function(data) { 
				data_value = data;
		}} );

		jQuery.ajax( {url: 'sanitizecontenthandler/' + file +'-attributes.html', async: false, success: function(data) {
				data_attributes = data.split(',');
				data_attributes.concat(defaultAttributes);
		}} );

		if (typeof data_attributes == undefined) {
			data_attributes = defaultAttributes;
		}

		for ( j=0; j<elements.length; j++ ) {
			tests.tests.push({
				start: '<' + elements[ j ] + '>' + data_start + '</' + elements[ j ] + '>',
				execResult: '<' + elements[ j ] + '>' + data_expected + '</' + elements[ j ] + '>',
				value: data_value,
				attributes: data_attributes
			});
		}
		
	};

	</script>
	<h1 id="qunit-header">Aloha Editor Paste Test Suite</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
	<div id="qunit-fixture"></div>
	<div id="edit" style="margin:20px; border:1px solid #000000;"></div>
	<div id="logBody"></div>
	</div>
</body>
</html>
